<style include="cr-shared-style shared-style cr-nav-menu-item-style">
  :host {
    display: block;
    --cr-vertical-tab-height: 33px;
  }

  .cr-nav-menu-item {
    color: var(--folder-inactive-color);
    /* Add enough space at the end for the focus outline to not be cropped. */
    margin-inline-end: 3px;
    padding: 0;
  }

  #inner-container {
    align-items: center;
    cursor: pointer;
    display: grid;
    flex: 1;
    grid-template-areas: 'arrow folder label';
    grid-template-columns: 24px 24px auto;
    min-height: 40px;
    min-width: fit-content;
    overflow: hidden;
    padding-inline-start: calc(var(--node-depth, 0) * 15px + 14px);
  }

  #arrow {
    grid-area: arrow;
    justify-self: center;
    margin: 0;
    --cr-icon-button-size: 40px;
    margin-inline-end: 10px;
  }

  #arrow:not([is-open]) {
    transform: rotate(-90deg);
    transition: transform 150ms;
  }

  .folder-icon {
    grid-area: folder;
    justify-self: center;
  }

  .menu-label {
    font-weight: 500;
    grid-area: label;
    padding: 0 6px;
    white-space: nowrap;
  }

  :host([is-selected-folder_]) .cr-nav-menu-item {
    color: var(--interactive-color);
  }

  @media (prefers-color-scheme: dark) {
    .cr-nav-menu-item.drag-on {
      color: var(--google-grey-700);
    }
  }

  :host-context([dir='rtl']) #arrow:not([is-open]) {
    transform: rotate(90deg);
  }

  #arrow[is-open] {
    transform: initial;
  }

  :host-context([enable-branding-update]) .cr-vertical-tab::before {
    display: none;
  }

  :host-context([enable-branding-update]) #inner-container {
    min-height: 0;
  }

  :host-context([enable-branding-update]) #container {
    min-width: fit-content;
    padding-inline-end: 10px;
  }

  :host-context([enable-branding-update]) #arrow {
    margin: 0;
  }
  
  paper-ripple {
    display: none;
  }

  :host-context([enable-branding-update]) paper-ripple {
    display: block;
  }

  @media (prefers-color-scheme: dark) {
    :host-context([enable-branding-update]) .cr-nav-menu-item[selected] #arrow,
    :host-context([enable-branding-update]) .cr-nav-menu-item.drag-on #arrow {
      --cr-icon-button-fill-color: black;
    }

    :host-context([enable-branding-update]) .cr-nav-menu-item.drag-on {
      --iron-icon-fill-color: black;
      background: var(--google-blue-300);
      color: var(--google-grey-900);
    }
  }
</style>

<div id="container"
    class$="cr-vertical-tab cr-nav-menu-item [[getContainerClass_(isSelectedFolder_)]]"
    hidden="[[isRootFolder_(depth)]]"
    role="treeitem"
    aria-owns="descendants"
    tabindex$="[[getTabIndex_(selectedFolder_, itemId)]]"
    on-click="selectFolder_"
    on-dblclick="toggleFolder_"
    on-contextmenu="onContextMenu_"
    selected$="[[isSelectedFolder_]]">
  <div id="inner-container">
    <template is="dom-if" if="[[hasChildFolder_]]">
      <cr-icon-button id="arrow" iron-icon="cr:arrow-drop-down"
          on-click="toggleFolder_" on-mousedown="preventDefault_"
          tabindex="-1" is-open$="[[isOpen]]" noink aria-hidden="true">
      </cr-icon-button>
    </template>
    <div class="folder-icon"
        open$="[[isSelectedFolder_]]"
        no-children$="[[!hasChildFolder_]]">
    </div>
    <div class="menu-label" title="[[item_.title]]">
      [[item_.title]]
    </div>
    <paper-ripple></paper-ripple>
  </div>
</div>
<div id="descendants" role="group">
  <template is="dom-if" if="[[isOpen]]">
    <template is="dom-repeat"
        items="[[item_.children]]"
        as="child"
        filter="isFolder_">
      <bookmarks-folder-node item-id="[[child]]"
          draggable="true"
          depth="[[getChildDepth_(depth)]]">
      </bookmarks-folder-node>
    </template>
  </template>
</div>
